package patterns.actions.memento.document;

import java.util.LinkedList;

public class VersionControlSystem {
	LinkedList<Backup> backups = new LinkedList<Backup>();

	int nextVersion;

	public void add(Backup backup) {
		backup.version = ++this.nextVersion;
		this.backups.add(backup);
	}

	public Backup get(int version) {
		for (Backup backup : this.backups) {
			if (backup.version == version) {
				return backup;
			}
		}
		return null;
	}
	
	public Backup getLastVersion(){
		return this.backups.getLast();
	}

}
